
const fs = require('fs');
const path = require('path');

var toolConfig = {

    _projPath:"",
    _protoPath:"",
    _excelPath:"",
    _webpExe:"",

    init(configFile){
        if(!fs.existsSync(configFile)){
            console.log("配置文件不存在")
            return false
        }
        let jsonData = JSON.parse(fs.readFileSync(configFile))
        this._protoPath = jsonData["proto"]
        this._projPath = jsonData["project"]
        this._excelPath = jsonData["excel"]        
        this._webpExe = jsonData["webExE"]
        return true
    },

    /**
     * 
     * @returns [proto_src,proto_define,proto_msg,proto_dts]
     */
    getProtoPath(){
        let exportProto = path.join(this._projPath,"assets/Script/Core/Enum")
        let msg = path.join(this._projPath,"assets/resources/config")
        let dts = path.join(this._projPath,"dts")
        return [this._protoPath,exportProto,msg,dts]
    },

    /**
     * 
     * @returns [excel_src,excel_json,excel_csv]
     */
    getExcelPath(){
        let exportExcel = path.join(this._projPath,"assets/resources/config")
        let excel_csv = path.join(this._projPath,"assets/Script/Core/Excel")
        return [this._excelPath,exportExcel,excel_csv]
    },
    /**
     * 
     * @returns path
     */
    getWechatPath(platform){
        if(platform == "wechat"){
            return path.join(this._projPath,"build/wechatgame")
        }else if(platform == "desktop"){
            return path.join(this._projPath,"build/web-desktop")
        }
    },
    getWebpExe(){
        return this._webpExe
    },
    



}
module.exports = toolConfig;